package club.justwill.single.helper;

import club.justwill.single.Tools;
import club.justwill.single.impl.ToolsImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;

public abstract class BaseHelper {
	private static final Logger logger = LoggerFactory.getLogger(BaseHelper.class);

	public static final long fiveMinutes = 5*60*1000;

	@Value("${fileStorageRoot}")
	protected String fileStorageRoot;

	@Autowired
	@Qualifier("tools")
	private ObjectFactory<Tools> toolsFactory;

	protected Tools getTools() {
		return toolsFactory.getObject();
	}

	public String getServiceName(String standardName) {
		if (standardName == null) {
			return ToolsImpl.EMPTY_STRING;
		}
		return standardName.substring(0, standardName.indexOf("Response"));
	}
}